home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / Translation.h < prev    next >
Text File  |  1995-07-06  |  12KB  |  310 lines

  1. /*
  2.      File:        Translation.h
  3.  
  4.      Contains:    Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __TRANSLATION__
  21. #define __TRANSLATION__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __FILES__
  30. #include <Files.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33. /*    #include <OSUtils.h>                                        */
  34. /*        #include <Memory.h>                                        */
  35. /*    #include <Finder.h>                                            */
  36.  
  37. #ifndef __COMPONENTS__
  38. #include <Components.h>
  39. #endif
  40.  
  41. #ifndef __TRANSLATIONEXTENSIONS__
  42. #include <TranslationExtensions.h>
  43. #endif
  44. /*    #include <Quickdraw.h>                                        */
  45. /*        #include <QuickdrawText.h>                                */
  46.  
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50.  
  51. #if PRAGMA_ALIGN_SUPPORTED
  52. #pragma options align=mac68k
  53. #endif
  54.  
  55. #if PRAGMA_IMPORT_SUPPORTED
  56. #pragma import on
  57. #endif
  58.  
  59. typedef short DocOpenMethod;
  60.  
  61.  
  62. enum {
  63.     domCannot,
  64.     domNative,
  65.     domTranslateFirst,
  66.     domWildcard
  67. };
  68.  
  69. /* 0L terminated array of OSTypes, or FileTypes*/
  70. typedef OSType TypesBlock[64];
  71.  
  72. typedef OSType *TypesBlockPtr;
  73.  
  74. /* Progress dialog resource ID*/
  75.  
  76. enum {
  77.     kTranslationScrapProgressDialogID = -16555
  78. };
  79.  
  80. /* block of data that describes how to translate*/
  81. struct FileTranslationSpec {
  82.     OSType                            componentSignature;
  83.     const void                        *translationSystemInfo;
  84.     FileTypeSpec                    src;
  85.     FileTypeSpec                    dst;
  86. };
  87. typedef struct FileTranslationSpec FileTranslationSpec;
  88.  
  89. typedef FileTranslationSpec *FileTranslationSpecArrayPtr;
  90.  
  91. /*****************************************************************************************
  92. *   GetFileTypesThatAppCanNativelyOpen
  93. *  This routine returns a list of all FileTypes that an application can open by itself
  94. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  95. *             appSignature        signature (creator) of application
  96. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  97. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  98. */
  99. extern pascal OSErr GetFileTypesThatAppCanNativelyOpen(short appVRefNumHint, OSType appSignature, FileType *nativeTypes)
  100.  TWOWORDINLINE(0x701C, 0xABFC);
  101. /*****************************************************************************************
  102. *  ExtendFileTypeList
  103. *  This routine makes a new list of file types that can be translated into a type in the given list
  104. *  Used by StandardFile
  105. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  106. *             numberOriginalTypes        number of file types in orgTypeList
  107. *              extendedTypeList        pointer to a buffer to be filled with file types
  108. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  109. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  110. *             numberExtendedTypes        number of file types put in extendedTypeList
  111. */
  112. extern pascal OSErr ExtendFileTypeList(const FileType *originalTypeList, short numberOriginalTypes, FileType *extendedTypeList, short *numberExtendedTypes)
  113.  TWOWORDINLINE(0x7009, 0xABFC);
  114. /*****************************************************************************************
  115. *  This routine checks if a file can be opened by a particular application.
  116. *  If so, it returns if it needs to be translated first, and if so then how.
  117. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  118. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  119. *  Enter:    targetDocument        document to check if it can be opened
  120. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  121. *             appSignature        signature (creator) of application to open doc
  122. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  123. *             onlyNative            whether to consider if document can be translated before opening
  124. *             howToOpen            pointer to buffer in which to put how the document can be opened
  125. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  126. *  Exit:    howToOpen            whether file needs to be translated to be read
  127. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  128. *             returns                noErr, noPrefAppErr
  129. */
  130. extern pascal OSErr CanDocBeOpened(const FSSpec *targetDocument, short appVRefNumHint, OSType appSignature, const FileType *nativeTypes, Boolean onlyNative, DocOpenMethod *howToOpen, FileTranslationSpec *howToTranslate)
  131.  TWOWORDINLINE(0x701E, 0xABFC);
  132. /*****************************************************************************************
  133. *  GetFileTranslationPaths
  134. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  135. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  136. *  Enter:    srcDoc            source file or NULL for all matches
  137. *             dstDoc            destination FileType or NULL for all matches
  138. *             maxResultCount
  139. *             resultBuffer
  140. *  Exit:    number of paths
  141. */
  142. extern pascal short GetFileTranslationPaths(FSSpec *srcDocument, FileType dstDocType, unsigned short maxResultCount, FileTranslationSpecArrayPtr resultBuffer)
  143.  TWOWORDINLINE(0x7038, 0xABFC);
  144. /*****************************************************************************************
  145. *  GetPathFromTranslationDialog
  146. *  This routine, with a given document, application, and a passed typelist will display the
  147. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  148. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  149. *  The routine returns the translation path information.
  150. *  Enter:    theDocument            FSSpec to document to open
  151. *             theApplication        FSSpec to application to open document
  152. *             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  153. *                                 you would like the documented translated to.  Order most perferred
  154. *                                 to least.
  155. *  Exit:    howToOpen            Translation method needed to open document
  156. *             howToTranslate        Translation specification
  157. *             returns                Any errors that might occur.
  158. */
  159. extern pascal OSErr GetPathFromTranslationDialog(const FSSpec *theDocument, const FSSpec *theApplication, TypesBlockPtr typeList, DocOpenMethod *howToOpen, FileTranslationSpec *howToTranslate)
  160.  TWOWORDINLINE(0x7037, 0xABFC);
  161. /*****************************************************************************************
  162. *   TranslateFile
  163. *  This routine reads a file of one format and writes it to another file in another format. 
  164. *  The information on how to translated is generated by the routine CanDocBeOpened.
  165. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  166. *  The destination file must not exist.  It is created by this routine.  
  167. *  Enter:    sourceDocument            input file to translate
  168. *             destinationDocument        output file of translation
  169. *             howToTranslate            pointer to info on how to translate
  170. *  Exit:    returns                    noErr, badTranslationSpecErr 
  171. */
  172. extern pascal OSErr TranslateFile(const FSSpec *sourceDocument, const FSSpec *destinationDocument, const FileTranslationSpec *howToTranslate)
  173.  TWOWORDINLINE(0x700C, 0xABFC);
  174. /*****************************************************************************************
  175. *   GetDocumentKindString
  176. *  This routine returns the string the Finder should show for the "kind" of a document
  177. *  in the GetInfo window and in the kind column of a list view.  
  178. *  Enter:    docVRefNum        The volume containing the document
  179. *             docType            The catInfo.fdType of the document
  180. *             docCreator        The catInfo.fdCreator of the document
  181. *             kindString        pointer to where to return the string
  182. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  183. *             returns            noErr, or afpItemNoFound if kind could not be determined
  184. */
  185. extern pascal OSErr GetDocumentKindString(short docVRefNum, OSType docType, OSType docCreator, Str63 kindString)
  186.  TWOWORDINLINE(0x7016, 0xABFC);
  187. /*****************************************************************************************
  188. *  GetTranslationExtensionName
  189. *  This routine returns the translation system name from a specified TranslationSpec
  190. *  Enter:    translationMethod    The translation path to get the translation name from
  191. *  Exit:    extensionName        The name of the translation system
  192. *             returns                Any errors that might occur
  193. */
  194. extern pascal OSErr GetTranslationExtensionName(const FileTranslationSpec *translationMethod, Str31 extensionName)
  195.  TWOWORDINLINE(0x7036, 0xABFC);
  196. /*****************************************************************************************
  197. *  GetScrapDataProcPtr
  198. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  199. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  200. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  201. *  with a list all the formats that you have available to be translated, and the length of each.
  202. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  203. *  the formats that 'fmts' list said was available.
  204. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  205. *             dataH                    Handle in which to put the requested data
  206. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  207. *             
  208. *  Exit:    dataH                    Handle is resized and filled with data in requested format
  209. */
  210. typedef pascal OSErr (*GetScrapDataProcPtr)(ScrapType requestedFormat, Handle dataH, void *srcDataGetterRefCon);
  211.  
  212. #if GENERATINGCFM
  213. typedef UniversalProcPtr GetScrapDataUPP;
  214. #else
  215. typedef GetScrapDataProcPtr GetScrapDataUPP;
  216. #endif
  217.  
  218. enum {
  219.     uppGetScrapDataProcInfo = kPascalStackBased
  220.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  221.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ScrapType)))
  222.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
  223.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void*)))
  224. };
  225.  
  226. #if GENERATINGCFM
  227. #define NewGetScrapDataProc(userRoutine)        \
  228.         (GetScrapDataUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture())
  229. #else
  230. #define NewGetScrapDataProc(userRoutine)        \
  231.         ((GetScrapDataUPP) (userRoutine))
  232. #endif
  233.  
  234. #if GENERATINGCFM
  235. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon)        \
  236.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetScrapDataProcInfo, (requestedFormat), (dataH), (srcDataGetterRefCon))
  237. #else
  238. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon)        \
  239.         (*(userRoutine))((requestedFormat), (dataH), (srcDataGetterRefCon))
  240. #endif
  241.  
  242. typedef GetScrapDataUPP GetScrapData;
  243.  
  244. /*****************************************************************************************
  245. *  TranslateScrap
  246. *  This routine resizes the destination handle and fills it with data of the requested format.
  247. *  The data is generated by translated one or more source formats of data supplied by
  248. *  the procedure srcDataGetter.  
  249. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  250. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  251. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  252. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  253. *             destinationFormat            Format of data desired
  254. *             destinationData                Handle in which to store translated data
  255. *             
  256. *  Exit:    dstData                        Handle is resized and filled with data in requested format
  257. */
  258. extern pascal OSErr TranslateScrap(GetScrapData sourceDataGetter, void *sourceDataGetterRefCon, ScrapType destinationFormat, Handle destinationData, short progressDialogID)
  259.  TWOWORDINLINE(0x700E, 0xABFC);
  260.  
  261. #if PRAGMA_IMPORT_SUPPORTED
  262. #pragma import off
  263. #endif
  264.  
  265. #if PRAGMA_ALIGN_SUPPORTED
  266. #pragma options align=reset
  267. #endif
  268.  
  269. #ifdef __cplusplus
  270. }
  271. #endif
  272.  
  273. #endif /* __TRANSLATION__ */
  274.